<?php

namespace think\filesystem\driver;

use League\Flysystem\AdapterInterface;
use think\facade\Db;
use think\filesystem\Driver;
use Overtrue\Flysystem\Qiniu\QiniuAdapter;

class Qiniu extends Driver{
    protected function createAdapter(): AdapterInterface{
        $uniacid = $_SERVER['HTTP_UNIACID'];
        $data = Db::table('ims_zst_marketing_memory')
            ->where('uniacid',$uniacid)
            ->findOrEmpty();

        return new QiniuAdapter(
            // 数据库获取TP配置信息
            $data['qn_accesskey'],
            $data['qn_secretkey'],
            $data['qn_bucket'],
            $data['qn_url']
        );
//          return new QiniuAdapter(
//            // 数据库获取TP配置信息
//            $this->config['accessKey'],
//            $this->config['secretKey'],
//            $this->config['bucket'],
//            $this->config['domain']
//        );
    }
}
